package net.gxf.common.util;

import java.util.Calendar;
import java.util.TimeZone;

/**
 * make a suitable time field
 * 
 * @author: maybe
 * 
 */
public class TimeFomartUtil {

	public static String getTimeAsString() {
		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
		// calendar.set(2012, 3, 3);
		int day_week = calendar.get(Calendar.DAY_OF_WEEK);
		if (day_week == 1) {// weekend
			calendar.add(Calendar.DAY_OF_MONTH, -2);
		}
		if (day_week == 7) {// weekend
			calendar.add(Calendar.DAY_OF_MONTH, -1);
		}
		int year = calendar.get(Calendar.YEAR);
		int month = calendar.get(Calendar.MONTH) + 1;
		int day = calendar.get(Calendar.DAY_OF_MONTH);
		// System.out.println(calendar.get(Calendar.HOUR_OF_DAY));

		return year + addZero(month) + addZero(day);
	}

	private static String addZero(int num) {
		return num < 10 ? "0" + num : String.valueOf(num);
	}

/*	public static void main(String[] args) {
		System.out.println(getTimeAsString());
	}*/

}
